#include "MainWindow.hpp"


MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent)
{
	setCentralWidget(new QFrame);
	QVBoxLayout *vbox = new QVBoxLayout;
	QHBoxLayout *hbox = new QHBoxLayout;
	left = new Drawing;
	left->uipara = &uipara;
	left->inpara = &inpara;
	right = new MatrixDrawing;
	bottom = new Panel;
	left->initializeGL();
	//right->initializeGL();
	hbox->addWidget(left);
	hbox->addWidget(right);
	vbox->addLayout(hbox);
	vbox->addWidget(bottom);
	centralWidget()->setLayout(vbox);



	connect(bottom, SIGNAL(setfilename(const char*)), &inpara, SLOT(readfile(const char*)));
	connect(&inpara, SIGNAL(initpara(double,double,double,double,double,double,double,double)),
			bottom, SLOT(initpara(double,double,double,double,double,double,double,double)));
	connect(bottom, SIGNAL(setstruct(bool,char)), &uipara, SLOT(setstruct(bool,char)));
	connect(bottom, SIGNAL(setcolor(int,int,int)), &uipara, SLOT(setcolor(int,int,int)));
	connect(bottom, SIGNAL(settrans(float,float,float)), &uipara, SLOT(settrans(float,float,float)));
	connect(bottom, SIGNAL(setrotat(float,float,float)), &uipara, SLOT(setrotat(float,float,float)));
	connect(bottom, SIGNAL(setclip(float,float)), &uipara, SLOT(setclip(float,float)));
	connect(&uipara, SIGNAL(refresh()), left, SLOT(refresh()));
	connect(&inpara, SIGNAL(reset()), left, SLOT(reset()));
	connect(bottom, SIGNAL(resetcam()), left, SLOT(reset()));


	//connect(bottom, SIGNAL(initialdrawing()), left, SLOT(Initalvalue()));

	/*
   // connect(right, SIGNAL(initpara(double,double,double,double,double,double,double,double)),
	//        bottom, SLOT(initpara(double,double,double,double,double,double,double,double)));
	connect(bottom, SIGNAL(setfilename(const char*)), right, SLOT(setfilename(const char*)));
	connect(bottom, SIGNAL(setstruct(bool,char)), right, SLOT(setstruct(bool,char)));
	connect(bottom, SIGNAL(setcolor(int,int,int)), right, SLOT(setcolor(int,int,int)));
	connect(bottom, SIGNAL(settrans(float,float,float)), right, SLOT(settrans(float,float,float)));
	connect(bottom, SIGNAL(setrotat(float,float,float)), right, SLOT(setrotat(float,float,float)));
	connect(bottom, SIGNAL(setclip(float,float)), right, SLOT(setclip(float,float)));
	//connect(bottom, SIGNAL(initialmatrixdrawing()), right, SLOT(Initalvalue()));
	*/
}

MainWindow::~MainWindow()
{

}
